package com.gxa.controller.xxh.FinancialManagement;

import com.gxa.common.R;
import com.gxa.common.vo.FinancialVo;
import com.gxa.entity.SysFinancial;
import com.gxa.service.FinancialManagementService;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@Api(value = "财务管理功能",tags = "财务管理功能API")
@RequestMapping(value = "/FinancialManagement/Financial")
@RequiresRoles(value = {"超级管理员","院长","主任"},logical = Logical.OR)
public class FinancialManagementController {
    @Autowired
    FinancialManagementService financialManagementService;
    /**
     * 查询所有财务列表
     * @param currentPage
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "/findFinancialList",method = RequestMethod.GET)
    @ApiOperation(value = "查询所有财务列表接口",notes = "查询所有财务列表",httpMethod = "GET",response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数默认第一页",paramType = "query",dataType = "String"),
            @ApiImplicitParam(name = "pageSize",value = "每页显示记录数",paramType = "query",dataType = "String")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R findFinancialList(Integer currentPage,Integer pageSize){

        return financialManagementService.findFinancialList(currentPage,pageSize);
    }

    /**
     * 新增财务
     * @param financialVo
     * @return
     */
    @RequestMapping(value = "/addFinancial",method = RequestMethod.POST)
    @ApiOperation(value = "新增财务接口",notes = "新增财务",httpMethod = "POST",response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R addFinancial(@RequestBody @ApiParam(name = "financialVo",value = "账户实体",required = true) FinancialVo financialVo){
        return financialManagementService.addFinancial(financialVo);
    }

    /**
     * 根据姓名查询财务信息
     * @param head
     * @param currentPage
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "/findFinancialByHead",method = RequestMethod.GET)
    @ApiOperation(value = "根据姓名查询财务信息接口",notes = "根据姓名查询财务信息",httpMethod = "GET",response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R findFinancialByHead(@RequestParam("head") String head, Integer currentPage, Integer pageSize){

        return financialManagementService.findFinancialByHead(head,currentPage,pageSize);
    }

    /**
     * 修改财务
     * @param sysFinancial
     * @return
     */
    @RequestMapping(value = "/updateFinancial",method = RequestMethod.POST)
    @ApiOperation(value = "修改财务接口",notes = "修改财务",httpMethod = "POST",response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R updateFinancial(@RequestBody @ApiParam(name = "sysFinancial",value = "财务实体",required = true) SysFinancial sysFinancial){

        return financialManagementService.updateFinancial(sysFinancial);
    }

    /**
     * 删除财务
     * @param id
     * @return
     */
    @RequestMapping(value = "/deleteFinancial",method = RequestMethod.POST)
    @ApiOperation(value = "删除财务接口",notes = "删除财务",httpMethod = "POST",response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R deleteFinancial(@RequestParam("id") Integer id){
        return financialManagementService.deleteFinancial(id);
    }
}

